<?php

include_once(dirname(__file__)."/../../globals.php");

function newpatient_report( $pid, $encounter, $cols, $id) {
        $query = "select * from form_encounter f 
							left join openemr_postcalendar_categories o ON f.pc_catid=o.pc_catid 
							left join procedure_type tc ON f.pc_typid = tc.procedure_type_id 
							where f.pid='$pid' and f.id='$id'";
	$res = sqlStatement($query);
        //die($query);
	//print "<ul>";
	while($result = sqlFetchArray($res)) {
		$cres = sqlFetchArray(sqlStatement("SELECT * FROM `list_options` WHERE list_id = 'Causa_de_la_consulta' AND seq='". $result{"pc_causaid"} . "' order by seq asc"));
		
		//$cres2 = sqlFetchArray(sqlStatement("SELECT * FROM `list_options` WHERE list_id = 'Conducta_a_seguir' AND seq='". $result{"pc_conductid"} . "' order by seq asc"));
    /*echo "<pre>";
	print_r($result); 
	echo "</pre>"; 
	die;*/
		print "<div id='resumen'>"; 
		print "<ul><li class=label><span class=bold>" . xl('Reason') . ": </span></li><li><span class=text>" . $result{"reason"} . "</li></ul>";
		print "<ul><li class=label><span class=bold>" . xl('Facility') . ": </span></li><li><span class=text>" . $result{"facility"} . "</li></ul>";
		print "<ul><li class=label><span class=bold>Tipo de consulta: </span></li><li><p class='text' style='width: 270px;padding:0;'>" . $result{"name"} . " (".$result{"procedure_code"}.")</p></li></ul>";
		print "<ul><li class=label><span class=bold>Categor&iacute;a de la Consulta: </span></li><li><span class=text>" . $result{"pc_catname"} . "</li></ul>";
		print "<ul><li class=label><span class=bold>Causa de la Consulta: </span></li><li><span class=text>" . $cres{"title"} . "</li></ul>"; 
		//print "<ul><li class=label><span class=bold>Conducta a seguir: </span></li><li><span class=text>" . $cres2{"title"} . "</li></ul>";
		print "</div>";
	}
	print "</ul>\n";
}

?>
